package me.ereach.casting;

public class Main {
    public static void main(String[] args) {
//        Person person = new Person("Tod", "male");
        Employee emp = new Employee("Tom", "male", 5000, 30, 20);
        Student student = new Student("Cherry", "Female", "C1", 2022);
        show(emp);
//        show(person);
        show(student);
    }

    public static void show(Person obj) {
        if (obj instanceof Employee) {
            Employee emp = (Employee) obj;
            emp.setName("Jerry");
            emp.setBaseSalary(8000);
        }
        else if (obj instanceof Student) {
            Student std = (Student) obj;
            std.setName("Lee Fei");
            std.setEnterYear(2021);
        }
        System.out.println(obj);
    }
}
